//
//  PlanItem.m
//  Water
//
//  Created by yh on 2017/11/27.
//  Copyright © 2017年 chenguibang. All rights reserved.
//

#import "PlanItem.h"
#import <YYKit/NSDate+YYAdd.h>
@implementation PlanItem

- (AppRemaidNotification *)notification{
    if (!_notification) {
        _notification = [[AppRemaidNotification alloc]init];
    }
    _notification.dateComponents = [[NSDateComponents alloc]init];
    _notification.dateComponents.hour = self.time.hour;
    _notification.dateComponents.minute = self.time.minute;
    _notification.title = @"饮水提醒";
    _notification.subtitle = [NSString stringWithFormat:@"%ld:%ld",(long)self.time.hour,(long)self.time.minute];
    _notification.body = @"来一杯";
    _notification.identifier = [NSString stringWithFormat:@"%@",self.time];
    return _notification;
}

+ (PlanItem *)planWithTag:(NSString *)tag
                     hour:(NSInteger)hour
                   minute:(NSInteger)minute
                   second:(NSInteger)second
                 isRemind:(BOOL)isRemind{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *components = [[NSDateComponents alloc]init];
    components.hour = hour;
    components.minute = minute;
    components.second = second;
    NSDate *date = [calendar dateFromComponents:components];
    PlanItem *item = [[PlanItem alloc]init];
    item.time = date;
    item.tag =  tag;
    item.isRemind = isRemind;
    return item;
    
}

@end
